//Concrete 混泥土
function ConcreteClass(){
	this.performTask = function(){
		this.preTask();
		console.log('doing something');
		this.postTask();
	}
}

//abstract 抽象的
function AbstractDecorator(decorated){
	this.performTask = function(){
		decorated.performTask();
	}
}

function ConcreteDecoratorClass(decorated){
	this.base = AbstractDecorator;
	this.base(decorated);

	decorated.preTask = function(){
		console.log('pre-calling..');
	}

	decorated.postTask = function(){
		console.log('post-calling..');
	}
}

var concrete = new ConcreteClass();

var decorator1 = new ConcreteDecoratorClass(concrete);
var decorator2 = new ConcreteDecoratorClass(decorator1)
decorator1.performTask();
decorator2.performTask();
